package info.brenstar.boxedin.core;

import org.newdawn.slick.*;
import org.newdawn.slick.geom.*;
import info.brenstar.boxedin.collisions.Sector;

/**
 * Base class for the game objects, sprites. A sprite has an image, a location, and a bounding box.
 * 
 * @author Brenstar
 *
 */
public abstract class Sprite {
	
	protected Image image;
	protected SpriteSheet sheet;
	protected boolean alive;
	protected float x, y;
	protected Shape mask;
	protected boolean collide;
	protected Sector sector;
	

	protected String resource;
	
	protected SpriteGroup group;
	protected Room room;
	
	

	public Sprite() { 
		this.alive = true;
		mask = new Rectangle(0,0,32,32);
	}
	
	public Sprite(float x, float y) {
		alive = true;
		this.x = x;
		this.y = y;
		mask = new Rectangle(0,0,32,32);
	}
	
	public Sprite(SpriteGroup group) {
		alive = true;
		group.add(this);
		assignGroup(group);
	}
	
	public abstract void init();
	public abstract void unload();
	public abstract void kill();
	
	public boolean isAlive() {
		return this.alive;
	}
	public Image getImage() {
		return image;
	}
	public void setImage(Image image) {
		this.image = image;
	}
	public SpriteSheet getSheet() {
		return sheet;
	}
	public void setSheet(SpriteSheet sheet) {
		this.sheet = sheet;
	}
	public float getX() {
		return this.x;
	}
	public float getY() {
		return this.y;
	}
	public void setX(float x) {
		this.x = x;
	}
	public void setY(float y) {
		this.y = y;
	}
	
	public Shape getMask() {
		mask.setX(x);
		mask.setY(y);
		return this.mask;
	}
	public void setMask(Shape mask) {
		this.mask = mask;
	}
	public void setAlive(boolean alive) {
		this.alive = alive;
	}
	
	public boolean isCollide() {
		return collide;
	}

	public void setCollide(boolean willCollide) {
		this.collide = willCollide;
	}
	
	public SpriteGroup getGroup() {
		return this.group;
	}
	public void assignGroup(SpriteGroup group) {
		if (this.group != group) {
			this.group = group;
		}
	}
	public Room getRoom() {
		return room;
	}

	public void setRoom(Room room) {
		this.room = room;
	}
	
	public Sector getSector() {
		return this.sector;
	}
	
	public void setSector(Sector sector) {
		this.sector = sector;
	}
	
}
